初始化不指定参数文件,如使用以下命令初始化:
./mysqld --initialize --user=mysql --basedir=/data/mysql/barry_mysql --datadir=/data/mysql/barry_mysql/data
初始化后 ibdata1文件大小是默认的12M,如果参数文件中指定的是1G,则启动报如下错误。
2017-07-27T03:16:41.916500Z mysqld_safe Logging to '/data/mysql/barry_mysql/logs/barry-mysql.err'. 2017-07-27T03:16:42.001140Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/barry_mysql/data 2017-07-27T03:16:42.158846Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set. 2017-07-27T03:16:42.462038Z 0 [ERROR] InnoDB: The Auto-extending innodb_system data file '/data/mysql/barry_mysql/data/ibdata1' is of a different size 768 pages (rounded down to MB) than specified in the .cnf file: initial 65536 pages, max 0 (relevant if non-zero) pages! 2017-07-27T03:16:42.462105Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 2017-07-27T03:16:43.563231Z 0 [ERROR] Plugin 'InnoDB' init function returned error. 2017-07-27T03:16:43.563302Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 2017-07-27T03:16:43.563323Z 0 [ERROR] Failed to initialize plugins. 2017-07-27T03:16:43.563338Z 0 [ERROR] Aborting 2017-07-27T03:16:43.626546Z mysqld_safe mysqld from pid file /data/mysql/barry_mysql/tmp/mysql.pid ended
如果修改参数文件为12M,则可以正常启动。
如果不修改参数文件,而是将ibdata1删除,起动后会重新生成个1G的ibdata1,那么启动会报如下错误,且报错的几个表不能正常查看。
2017-07-27T03:41:16.224833Z 0 [Warning] InnoDB: New log files created, LSN=45791 mysqld: Table 'mysql.plugin' doesn't exist mysqld: Table 'mysql.gtid_executed' doesn't exist 2017-07-27T03:41:16.371369Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2017-07-27T03:41:16.413614Z 0 [Warning] CA certificate ca.pem is self signed. 2017-07-27T03:38:27.049543Z 3 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode. 2017-07-27T03:38:27.050140Z 3 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-07-27T03:40:01.619183Z mysqld_safe mysqld from pid file /data/mysql/barry_mysql/tmp/mysql.pid ended 2017-07-27T03:41:04.955142Z mysqld_safe Logging to '/data/mysql/barry_mysql/logs/barry-mysql.err'. 2017-07-27T03:41:05.040377Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/barry_mysql/data 2017-07-27T03:41:05.190872Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set. 100 200 300 400 500 600 700 800 900 1000 100 200 300 400 500 600 700 800 900 1000 100 200 300 400 500 600 700 800 900 1000 100 200 300 400 500 600 700 800 900 1000 2017-07-27T03:41:16.224833Z 0 [Warning] InnoDB: New log files created, LSN=45791 2017-07-27T03:41:16.275795Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-07-27T03:41:16.366508Z 0 [Warning] InnoDB: Cannot open table mysql/plugin from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue. mysqld: Table 'mysql.plugin' doesn't exist 2017-07-27T03:41:16.366637Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 2017-07-27T03:41:16.371317Z 0 [Warning] InnoDB: Cannot open table mysql/gtid_executed from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue. mysqld: Table 'mysql.gtid_executed' doesn't exist 2017-07-27T03:41:16.371369Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2017-07-27T03:41:16.413614Z 0 [Warning] CA certificate ca.pem is self signed. 2017-07-27T03:41:16.415576Z 0 [Warning] InnoDB: Cannot open table mysql/server_cost from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue. 2017-07-27T03:41:16.415629Z 0 [Warning] Failed to open optimizer cost constant tables 2017-07-27T03:41:16.416613Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode. 2017-07-27T03:41:16.416702Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-07-27T03:41:16.416761Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-07-27T03:41:16.416792Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode. 2017-07-27T03:41:16.416986Z 0 [Warning] InnoDB: Cannot open table mysql/time_zone_leap_second from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue. 2017-07-27T03:41:16.417023Z 0 [Warning] Can't open and lock time zone table: Table 'mysql.time_zone_leap_second' doesn't exist trying to live without them 2017-07-27T03:41:16.417647Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-07-27T03:41:16.417846Z 0 [Warning] InnoDB: Cannot open table mysql/servers from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue. 2017-07-27T03:41:16.417874Z 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist 2017-07-27T03:41:16.418373Z 0 [Warning] InnoDB: Cannot open table mysql/slave_master_info from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue. 2017-07-27T03:41:16.418579Z 0 [Warning] InnoDB: Cannot open table mysql/slave_relay_log_info from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue. 2017-07-27T03:41:16.418763Z 0 [Warning] InnoDB: Cannot open table mysql/slave_master_info from the internal data dictionary of InnoDB though the .frm file for the table exists. Please refer to http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html for how to resolve the issue. 2017-07-27T03:41:16.418798Z 0 [Warning] Info table is not ready to be used. Table 'mysql.slave_master_info' cannot be opened. 2017-07-27T03:41:16.418819Z 0 [ERROR] Error in checking mysql.slave_master_info repository info type of TABLE. 2017-07-27T03:41:16.418833Z 0 [ERROR] Error creating master info: Error checking repositories. 2017-07-27T03:41:16.418842Z 0 [ERROR] Failed to create or recover replication info repository. 2017-07-27T03:41:16.418857Z 0 [ERROR] Failed to create or recover replication info repositories.
根据以上实验总结:
(1) 初始化的时候 应该指定参数文件,这样ibdata1就是自己设定的1G
./bin/mysqld --defaults-file=/data/mysql/barry_mysql/etc/my.cnf --initialize-insecure --user=mysql
(2) ibdata1初始化后不能删除,靠重启生成的ibdata1不可用。因为里面保存了系统表的数据。